<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {

  public function index() {
    $this -> display();
  }
  /**
   * 管理员登录
   * @return [type] [description]
   */
  public function doAdminLogin() {
    $adminModel = M('admin');

    $adminLoginData['adminname'] = I('post.adminname');
    $adminLoginData['password'] = I('post.adminpassword');

    $res = $adminModel -> where($adminLoginData) -> find();

    if ($res) {
      session("adminId", $res['adminid']);
      session("adminName", $res['adminname']);
      $this -> success("管理员登录成功！", U('Club/clublist'));
    } else {
      $this -> error("用户名密码错误！");
    }

  }





  
    public function deltravel($id){
       $res=M("travel")->delete($id);
       // if($res)
       // 	$this->success("删除成功");
       // else $this->error("删除失败");
       echo M("travel")->getLastSQL();
    }
      public function addtype(){
      $tp=M('types');
      //方法1
      $data["typename"]=$_GET["typename"];
      if(false !== $tp->add($data)){
        $this->success('添加成功!');
      }
      else{
        $this->error('数据错误');
      }
      
    }
    
     public function upload()
    {
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize = 4000000;// 设置附件上传大小
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath = './Public/Upload/'; // 设置附件上传根目录
        //$upload->savePath  =     ''; // 设置附件上传（子）目录
        $upload->autoSub = false;
        $info = $upload->upload();  // 上传文件
       
        if (!$info) {
            $this->error($upload->getError());
        } else {
            //$this->success('上传成功！');
            return $info;
        }
    }

   
}
